package org.dreamwork.jasmine2.web.controls.datagrid;

import org.dreamwork.jasmine2.web.controls.WebContainer;

import java.util.Comparator;

/**
 * Created by IntelliJ IDEA.
 * User: seth.yang
 * Date: 2010-10-14
 * Time: 16:16:01
 */
public class GroupControl extends WebContainer {
    private String by, to;
    private GroupSummary summary;
    private Position position;
    private Comparator comparator;
    private String title;

    public GroupControl () {
        htmlTagName = "";
        viewStateEnabled = false;
    }

    public String getBy () {
        return by;
    }

    public void setBy (String by) {
        this.by = by;
    }

    public GroupSummary getSummary () {
        return summary;
    }

    public void setSummary (GroupSummary summary) {
        this.summary = summary;
    }

    public Position getPosition () {
        return position;
    }

    public void setPosition (Position position) {
        this.position = position;
    }

    public Comparator getComparator () {
        return comparator == null ? comparator = new DefaultComparetor (by) : comparator;
    }

    public void setComparator (Comparator comparator) {
        this.comparator = comparator;
    }

    public String getTitle () {
        return title;
    }

    public void setTitle (String title) {
        this.title = title;
    }

    public String getTo () {
        return to;
    }

    public void setTo (String to) {
        this.to = to;
    }

    @Override
    public void init () {
        super.init ();
        ((DataGrid) parent).groups.add (this);
    }
}